#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QSqlRelationalDelegate>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    model = new QSqlRelationalTableModel(this);
    model->setEditStrategy(QSqlTableModel::OnFieldChange);
    model->setTable("acctview");
    //model->setRelation(2,QSqlRelation("course","id","name"));
    model->setHeaderData(0,Qt::Horizontal,QObject::tr("ID"));
    model->setHeaderData(1,Qt::Horizontal,QObject::tr("Time_stamp"));
    model->setHeaderData(2,Qt::Horizontal,QObject::tr("Api_source"));
    model->setHeaderData(3,Qt::Horizontal,QObject::tr("BrokerId"));
    model->setHeaderData(4,Qt::Horizontal,QObject::tr("Accountid"));
    model->select();
    ui->tableView->setModel(model);
    ui->tableView->setItemDelegate(new QSqlRelationalDelegate(ui->tableView));
}

MainWindow::~MainWindow()
{
    delete ui;
}
